﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.Services;
using BLL.Theme;

namespace UI
{
    /// <summary>
    /// Summary description for wsTheme
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    public class wsTheme : WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod]
        public string[] GetCompletionList(string prefixText, int count)
        {
            List<ThemeBO> boList = ThemeBLL.GetThemes().Where(t => t.Libelle.ToLower().StartsWith(prefixText)).ToList();


            string[] themes = new string[boList.Count];

            for (int i = 0; i < boList.Count; i++)
            {
                themes[i] = boList[i].Libelle;
            }

            return themes;
        }
    }
}
